package top.xzxsrq.web.utils;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ZipUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.io.IOUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.util.StringUtils;
import sun.awt.image.BufferedImageGraphicsConfig;
import top.xzxsrq.common.utils.FileUtilsZX;
import top.xzxsrq.utils.PathUtils;

import javax.activation.MimetypesFileTypeMap;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;

@Log4j2
public abstract class WebUtils {
    public static final String split = "；；";

    public static void renderString(HttpServletResponse response, Object msg) throws IOException {
        // 处理编码方式 防止中文乱码
        response.setContentType("text/json;charset=utf-8");
        // 将反馈塞到HttpServletResponse中返回给前台
        response.getWriter().write(JSON.toJSONString(msg));
    }

    public static <T> T getBody(HttpServletRequest request, Class<T> clazz) {
        try (InputStream is = request.getInputStream()) {
            String string = IOUtils.toString(is, StandardCharsets.UTF_8);
            return JSON.parseObject(string, clazz);
        } catch (IOException ex) {
            log.error("read http request failed.", ex);
            return JSON.parseObject("", clazz);
        }
    }

    public static void rangeReadFile(String fileAbPath, HttpServletRequest request, HttpServletResponse response) {
        rangeReadFile(fileAbPath, request, response, getFileType(fileAbPath));
    }

    /**
     * 就是抄的这里
     * https://blog.csdn.net/qq_41787812/article/details/129662076
     *
     * @param fileAbPath
     * @param request
     * @param response
     * @param contentType
     */
    public static void rangeReadFile(String fileAbPath, HttpServletRequest request, HttpServletResponse response, String contentType) {
        //path为本地文件路劲
        RandomAccessFile targetFile = null;
        OutputStream outputStream = null;
        try {
            outputStream = response.getOutputStream();
            response.reset();
            //获取请求头中Range的值
            String rangeString = request.getHeader(HttpHeaders.RANGE);

            //打开文件
            File file = new File(fileAbPath);
            if (file.exists()) {
                //使用RandomAccessFile读取文件
                targetFile = new RandomAccessFile(file, "r");
                long fileLength = targetFile.length();
                long requestSize = (int) fileLength;
                //分段下载视频
                if (StringUtils.hasText(rangeString)) {
                    //从Range中提取需要获取数据的开始和结束位置
                    long requestStart = 0, requestEnd = 0;
                    String[] ranges = rangeString.split("=");
                    if (ranges.length > 1) {
                        String[] rangeDatas = ranges[1].split("-");
                        requestStart = Integer.parseInt(rangeDatas[0]);
                        if (rangeDatas.length > 1) {
                            requestEnd = Integer.parseInt(rangeDatas[1]);
                        }
                    }
                    if (requestEnd != 0 && requestEnd > requestStart) {
                        requestSize = requestEnd - requestStart + 1;
                    }
                    //根据协议设置请求头
                    response.setHeader(HttpHeaders.ACCEPT_RANGES, "bytes");
                    response.setHeader(HttpHeaders.CONTENT_TYPE, contentType);
                    if (!StringUtils.hasText(rangeString)) {
                        response.setHeader(HttpHeaders.CONTENT_LENGTH, fileLength + "");
                    } else {
                        long length;
                        if (requestEnd > 0) {
                            length = requestEnd - requestStart + 1;
                            response.setHeader(HttpHeaders.CONTENT_LENGTH, "" + length);
                            response.setHeader(HttpHeaders.CONTENT_RANGE, "bytes " + requestStart + "-" + requestEnd + "/" + fileLength);
                        } else {
                            length = fileLength - requestStart;
                            response.setHeader(HttpHeaders.CONTENT_LENGTH, "" + length);
                            response.setHeader(HttpHeaders.CONTENT_RANGE, "bytes " + requestStart + "-" + (fileLength - 1) + "/"
                                    + fileLength);
                        }
                    }
                    //断点传输下载视频返回206
                    response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
                    //设置targetFile，从自定义位置开始读取数据
                    targetFile.seek(requestStart);
                } else {
                    //如果Range为空则下载整个视频
                    response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode(file.getName(), "utf8"));
                    //设置文件长度
                    response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileLength));
                }

                //从磁盘读取数据流返回
                byte[] cache = new byte[4096];
                try {
                    while (requestSize > 0) {
                        int len = targetFile.read(cache);
                        if (requestSize < cache.length) {
                            outputStream.write(cache, 0, (int) requestSize);
                        } else {
                            outputStream.write(cache, 0, len);
                            if (len < cache.length) {
                                break;
                            }
                        }
                        requestSize -= cache.length;
                    }
                } catch (IOException e) {
                    // tomcat原话。写操作IO异常几乎总是由于客户端主动关闭连接导致，所以直接吃掉异常打日志
                    //比如使用video播放视频时经常会发送Range为0- 的范围只是为了获取视频大小，之后就中断连接了
                    log.info(e.getMessage());
                }
            } else {
                throw new RuntimeException("文件路劲有误");
            }
            outputStream.flush();
        } catch (Exception e) {
            log.error("文件传输错误：{}", fileAbPath, e);
            throw new RuntimeException("文件传输错误");
        } finally {
            if (outputStream != null) {
                try {
                    // 关闭请求流
                    outputStream.flush();
                } catch (IOException e) {
                    log.error("流释放错误flush：{}", fileAbPath, e);
                }
                try {
                    outputStream.close();
                } catch (IOException e) {
                    log.error("流释放错误：{}", fileAbPath, e);
                }
            }
            if (targetFile != null) {
                try {
                    targetFile.close();
                } catch (IOException e) {
                    log.error("文件流释放错误：{}", fileAbPath, e);
                }
            }
        }
    }

    public static void downloadFile(String filePath, HttpServletResponse response) throws IOException {
        downloadFile(new File(filePath), response);
    }

    public static void downloadFile(File file, HttpServletResponse response) throws IOException {
        // 设置响应头信息
        String filename = file.getName();
        // 设置response的Header
        response.setCharacterEncoding("UTF-8");
        // 指定下载文件名(attachment-以下载方式保存到本地，inline-在线预览)
        response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));
        // 告知浏览器文件的大小
        response.addHeader("Content-Length", String.valueOf(file.length()));
        MimetypesFileTypeMap mimetypesFileTypeMap = new MimetypesFileTypeMap();
        String contentType = mimetypesFileTypeMap.getContentType(file);
        // 内容类型为通用类型，表示二进制数据流
        response.setContentType(contentType);
        try (InputStream is = Files.newInputStream(file.toPath());
             BufferedInputStream bis = new BufferedInputStream(is);
             BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream())) {
            byte[] buff = new byte[2048];
            int len;
            while ((len = bis.read(buff)) != -1) {
                bos.write(buff, 0, len);
            }
            bos.flush();
        }
    }

    public static void downloadZipFile(List<String> fileApPaths, String basePath, String filename, HttpServletResponse response) throws IOException {
        List<FileInputStream> fileInputStreams = new LinkedList<>();
        List<String> toZipFileApPaths = new LinkedList<>();
        for (String fileApPath : fileApPaths) {
            File file = new File(fileApPath);
            boolean directory = file.isDirectory();
            if (directory) {
                for (File listFile : FileUtilsZX.listFiles(file, null, true)) {
                    String canonicalPath = PathUtils.getCanonicalPath(listFile);
                    log.info("canonicalPath = " + canonicalPath);
                    toZipFileApPaths.add(canonicalPath.replace(basePath, ""));
                    fileInputStreams.add(new FileInputStream(listFile));
                }
            } else {
                toZipFileApPaths.add(PathUtils.getCanonicalPath(fileApPath).replace(basePath, ""));
                fileInputStreams.add(new FileInputStream(fileApPath));
            }
        }
        log.info("基础路径：{}", basePath);
        log.info("附件的绝对路径：{}", fileApPaths.toString());
        log.info("生成的附件路径：{}", toZipFileApPaths.toString());
        // 设置response的Header
        response.setCharacterEncoding("UTF-8");
        // 指定下载文件名(attachment-以下载方式保存到本地，inline-在线预览)
        response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));
        response.setContentType("application/zip");
        ZipUtil.zip(response.getOutputStream(), toZipFileApPaths.toArray(new String[]{}), fileInputStreams.toArray(new FileInputStream[]{}));
    }

    public static String uuid64() {
        return uuid64(64);
    }

    public static String uuid64(int length) {
        StringBuilder s = new StringBuilder(UUID.randomUUID().toString().replaceAll("-", ""));
        while (s.length() < length) {
            s.append(UUID.randomUUID().toString().replaceAll("-", ""));
        }
        return s.substring(0, length);
    }

    public static void readFile(String fileAbPath, HttpServletRequest request, HttpServletResponse response) throws IOException {
        //设置内容类型
        response.setHeader("Content-Type", getFileType(fileAbPath));
        response.setStatus(HttpServletResponse.SC_OK);
        File file = new File(fileAbPath);
        // 告知浏览器文件的大小
        response.addHeader("Content-Length", String.valueOf(file.length()));
        try (InputStream is = Files.newInputStream(file.toPath());
             BufferedInputStream bis = new BufferedInputStream(is);
             BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream())) {
            byte[] buff = new byte[2048];
            int len;
            while ((len = bis.read(buff)) != -1) {
                bos.write(buff, 0, len);
            }
            bos.flush();
        } catch (IOException e) {
            log.error("文件传输错误：{}", fileAbPath, e);
            throw e;
        }
    }

    public static void getFileIcon(String fileAbPath, HttpServletRequest request, HttpServletResponse response) throws IOException {
        //设置内容类型
        response.setHeader("Content-Type", getFileTypeEnd("png"));
        response.setStatus(HttpServletResponse.SC_OK);
        File file = new File(fileAbPath);
        Icon systemIcon = FileSystemView.getFileSystemView().getSystemIcon(file);
        int height = systemIcon.getIconHeight();
        int width = systemIcon.getIconWidth();
        Image image = ((ImageIcon) systemIcon).getImage();
        BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        BufferedImageGraphicsConfig config = BufferedImageGraphicsConfig.getConfig(bufferedImage);
        bufferedImage =config.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
        Graphics g = bufferedImage.getGraphics();
        g.drawImage(image, 0, 0, width, height, null);
        g.dispose();
        ImageIO.write(bufferedImage, "png", response.getOutputStream());
    }

    public static String getFileType(String fileAbPath) {
        File file = new File(fileAbPath);
        String suffix = FileUtil.getSuffix(file);
        String lowerCase = suffix.toLowerCase();
        return getFileTypeEnd(lowerCase);
    }

    public static String getFileTypeEnd(String lowerCase) {
        if ("load".equals(lowerCase)) {
            return "text/html";
        }
        if ("123".equals(lowerCase)) {
            return "application/vnd.lotus-1-2-3";
        }
        if ("3ds".equals(lowerCase)) {
            return "image/x-3ds";
        }
        if ("3g2".equals(lowerCase)) {
            return "video/3gpp";
        }
        if ("3ga".equals(lowerCase)) {
            return "video/3gpp";
        }
        if ("3gp".equals(lowerCase)) {
            return "video/3gpp";
        }
        if ("3gpp".equals(lowerCase)) {
            return "video/3gpp";
        }
        if ("602".equals(lowerCase)) {
            return "application/x-t602";
        }
        if ("669".equals(lowerCase)) {
            return "audio/x-mod";
        }
        if ("7z".equals(lowerCase)) {
            return "application/x-7z-compressed";
        }
        if ("a".equals(lowerCase)) {
            return "application/x-archive";
        }
        if ("aac".equals(lowerCase)) {
            return "audio/mp4";
        }
        if ("abw".equals(lowerCase)) {
            return "application/x-abiword";
        }
        if ("abw.crashed".equals(lowerCase)) {
            return "application/x-abiword";
        }
        if ("abw.gz".equals(lowerCase)) {
            return "application/x-abiword";
        }
        if ("ac3".equals(lowerCase)) {
            return "audio/ac3";
        }
        if ("ace".equals(lowerCase)) {
            return "application/x-ace";
        }
        if ("adb".equals(lowerCase)) {
            return "text/x-adasrc";
        }
        if ("ads".equals(lowerCase)) {
            return "text/x-adasrc";
        }
        if ("afm".equals(lowerCase)) {
            return "application/x-font-afm";
        }
        if ("ag".equals(lowerCase)) {
            return "image/x-applix-graphics";
        }
        if ("ai".equals(lowerCase)) {
            return "application/illustrator";
        }
        if ("aif".equals(lowerCase)) {
            return "audio/x-aiff";
        }
        if ("aifc".equals(lowerCase)) {
            return "audio/x-aiff";
        }
        if ("aiff".equals(lowerCase)) {
            return "audio/x-aiff";
        }
        if ("al".equals(lowerCase)) {
            return "application/x-perl";
        }
        if ("alz".equals(lowerCase)) {
            return "application/x-alz";
        }
        if ("amr".equals(lowerCase)) {
            return "audio/amr";
        }
        if ("ani".equals(lowerCase)) {
            return "application/x-navi-animation";
        }
        if ("anim[1-9j]".equals(lowerCase)) {
            return "video/x-anim";
        }
        if ("anx".equals(lowerCase)) {
            return "application/annodex";
        }
        if ("ape".equals(lowerCase)) {
            return "audio/x-ape";
        }
        if ("arj".equals(lowerCase)) {
            return "application/x-arj";
        }
        if ("arw".equals(lowerCase)) {
            return "image/x-sony-arw";
        }
        if ("as".equals(lowerCase)) {
            return "application/x-applix-spreadsheet";
        }
        if ("asc".equals(lowerCase)) {
            return "text/plain";
        }
        if ("asf".equals(lowerCase)) {
            return "video/x-ms-asf";
        }
        if ("asp".equals(lowerCase)) {
            return "application/x-asp";
        }
        if ("ass".equals(lowerCase)) {
            return "text/x-ssa";
        }
        if ("asx".equals(lowerCase)) {
            return "audio/x-ms-asx";
        }
        if ("atom".equals(lowerCase)) {
            return "application/atom+xml";
        }
        if ("au".equals(lowerCase)) {
            return "audio/basic";
        }
        if ("avi".equals(lowerCase)) {
            return "video/x-msvideo";
        }
        if ("aw".equals(lowerCase)) {
            return "application/x-applix-word";
        }
        if ("awb".equals(lowerCase)) {
            return "audio/amr-wb";
        }
        if ("awk".equals(lowerCase)) {
            return "application/x-awk";
        }
        if ("axa".equals(lowerCase)) {
            return "audio/annodex";
        }
        if ("axv".equals(lowerCase)) {
            return "video/annodex";
        }
        if ("bak".equals(lowerCase)) {
            return "application/x-trash";
        }
        if ("bcpio".equals(lowerCase)) {
            return "application/x-bcpio";
        }
        if ("bdf".equals(lowerCase)) {
            return "application/x-font-bdf";
        }
        if ("bib".equals(lowerCase)) {
            return "text/x-bibtex";
        }
        if ("bin".equals(lowerCase)) {
            return "application/octet-stream";
        }
        if ("blend".equals(lowerCase)) {
            return "application/x-blender";
        }
        if ("blender".equals(lowerCase)) {
            return "application/x-blender";
        }
        if ("bmp".equals(lowerCase)) {
            return "image/bmp";
        }
        if ("bz".equals(lowerCase)) {
            return "application/x-bzip";
        }
        if ("bz2".equals(lowerCase)) {
            return "application/x-bzip";
        }
        if ("c".equals(lowerCase)) {
            return "text/x-csrc";
        }
        if ("c++".equals(lowerCase)) {
            return "text/x-c++src";
        }
        if ("cab".equals(lowerCase)) {
            return "application/vnd.ms-cab-compressed";
        }
        if ("cb7".equals(lowerCase)) {
            return "application/x-cb7";
        }
        if ("cbr".equals(lowerCase)) {
            return "application/x-cbr";
        }
        if ("cbt".equals(lowerCase)) {
            return "application/x-cbt";
        }
        if ("cbz".equals(lowerCase)) {
            return "application/x-cbz";
        }
        if ("cc".equals(lowerCase)) {
            return "text/x-c++src";
        }
        if ("cdf".equals(lowerCase)) {
            return "application/x-netcdf";
        }
        if ("cdr".equals(lowerCase)) {
            return "application/vnd.corel-draw";
        }
        if ("cer".equals(lowerCase)) {
            return "application/x-x509-ca-cert";
        }
        if ("cert".equals(lowerCase)) {
            return "application/x-x509-ca-cert";
        }
        if ("cgm".equals(lowerCase)) {
            return "image/cgm";
        }
        if ("chm".equals(lowerCase)) {
            return "application/x-chm";
        }
        if ("chrt".equals(lowerCase)) {
            return "application/x-kchart";
        }
        if ("class".equals(lowerCase)) {
            return "application/x-java";
        }
        if ("cls".equals(lowerCase)) {
            return "text/x-tex";
        }
        if ("cmake".equals(lowerCase)) {
            return "text/x-cmake";
        }
        if ("cpio".equals(lowerCase)) {
            return "application/x-cpio";
        }
        if ("cpio.gz".equals(lowerCase)) {
            return "application/x-cpio-compressed";
        }
        if ("cpp".equals(lowerCase)) {
            return "text/x-c++src";
        }
        if ("cr2".equals(lowerCase)) {
            return "image/x-canon-cr2";
        }
        if ("crt".equals(lowerCase)) {
            return "application/x-x509-ca-cert";
        }
        if ("crw".equals(lowerCase)) {
            return "image/x-canon-crw";
        }
        if ("cs".equals(lowerCase)) {
            return "text/x-csharp";
        }
        if ("csh".equals(lowerCase)) {
            return "application/x-csh";
        }
        if ("css".equals(lowerCase)) {
            return "text/css";
        }
        if ("cssl".equals(lowerCase)) {
            return "text/css";
        }
        if ("csv".equals(lowerCase)) {
            return "text/csv";
        }
        if ("cue".equals(lowerCase)) {
            return "application/x-cue";
        }
        if ("cur".equals(lowerCase)) {
            return "image/x-win-bitmap";
        }
        if ("cxx".equals(lowerCase)) {
            return "text/x-c++src";
        }
        if ("d".equals(lowerCase)) {
            return "text/x-dsrc";
        }
        if ("dar".equals(lowerCase)) {
            return "application/x-dar";
        }
        if ("dbf".equals(lowerCase)) {
            return "application/x-dbf";
        }
        if ("dc".equals(lowerCase)) {
            return "application/x-dc-rom";
        }
        if ("dcl".equals(lowerCase)) {
            return "text/x-dcl";
        }
        if ("dcm".equals(lowerCase)) {
            return "application/dicom";
        }
        if ("dcr".equals(lowerCase)) {
            return "image/x-kodak-dcr";
        }
        if ("dds".equals(lowerCase)) {
            return "image/x-dds";
        }
        if ("deb".equals(lowerCase)) {
            return "application/x-deb";
        }
        if ("der".equals(lowerCase)) {
            return "application/x-x509-ca-cert";
        }
        if ("desktop".equals(lowerCase)) {
            return "application/x-desktop";
        }
        if ("dia".equals(lowerCase)) {
            return "application/x-dia-diagram";
        }
        if ("diff".equals(lowerCase)) {
            return "text/x-patch";
        }
        if ("divx".equals(lowerCase)) {
            return "video/x-msvideo";
        }
        if ("djv".equals(lowerCase)) {
            return "image/vnd.djvu";
        }
        if ("djvu".equals(lowerCase)) {
            return "image/vnd.djvu";
        }
        if ("dng".equals(lowerCase)) {
            return "image/x-adobe-dng";
        }
        if ("doc".equals(lowerCase)) {
            return "application/msword";
        }
        if ("docbook".equals(lowerCase)) {
            return "application/docbook+xml";
        }
        if ("docm".equals(lowerCase)) {
            return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
        }
        if ("docx".equals(lowerCase)) {
            return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
        }
        if ("dot".equals(lowerCase)) {
            return "text/vnd.graphviz";
        }


        if ("dsl".equals(lowerCase)) {
            return "text/x-dsl";
        }
        if ("dtd".equals(lowerCase)) {
            return "application/xml-dtd";
        }
        if ("dtx".equals(lowerCase)) {
            return "text/x-tex";
        }
        if ("dv".equals(lowerCase)) {
            return "video/dv";
        }
        if ("dvi".equals(lowerCase)) {
            return "application/x-dvi";
        }
        if ("dvi.bz2".equals(lowerCase)) {
            return "application/x-bzdvi";
        }
        if ("dvi.gz".equals(lowerCase)) {
            return "application/x-gzdvi";
        }
        if ("dwg".equals(lowerCase)) {
            return "image/vnd.dwg";
        }
        if ("dxf".equals(lowerCase)) {
            return "image/vnd.dxf";
        }
        if ("e".equals(lowerCase)) {
            return "text/x-eiffel";
        }
        if ("egon".equals(lowerCase)) {
            return "application/x-egon";
        }
        if ("eif".equals(lowerCase)) {
            return "text/x-eiffel";
        }
        if ("el".equals(lowerCase)) {
            return "text/x-emacs-lisp";
        }
        if ("emf".equals(lowerCase)) {
            return "image/x-emf";
        }
        if ("emp".equals(lowerCase)) {
            return "application/vnd.emusic-emusic_package";
        }
        if ("ent".equals(lowerCase)) {
            return "application/xml-external-parsed-entity";
        }
        if ("eps".equals(lowerCase)) {
            return "image/x-eps";
        }
        if ("eps.bz2".equals(lowerCase)) {
            return "image/x-bzeps";
        }
        if ("eps.gz".equals(lowerCase)) {
            return "image/x-gzeps";
        }
        if ("epsf".equals(lowerCase)) {
            return "image/x-eps";
        }
        if ("epsf.bz2".equals(lowerCase)) {
            return "image/x-bzeps";
        }
        if ("epsf.gz".equals(lowerCase)) {
            return "image/x-gzeps";
        }
        if ("epsi".equals(lowerCase)) {
            return "image/x-eps";
        }
        if ("epsi.bz2".equals(lowerCase)) {
            return "image/x-bzeps";
        }
        if ("epsi.gz".equals(lowerCase)) {
            return "image/x-gzeps";
        }
        if ("epub".equals(lowerCase)) {
            return "application/epub+zip";
        }
        if ("erl".equals(lowerCase)) {
            return "text/x-erlang";
        }
        if ("es".equals(lowerCase)) {
            return "application/ecmascript";
        }
        if ("etheme".equals(lowerCase)) {
            return "application/x-e-theme";
        }
        if ("etx".equals(lowerCase)) {
            return "text/x-setext";
        }
        if ("exe".equals(lowerCase)) {
            return "application/x-ms-dos-executable";
        }
        if ("exr".equals(lowerCase)) {
            return "image/x-exr";
        }
        if ("ez".equals(lowerCase)) {
            return "application/andrew-inset";
        }
        if ("f".equals(lowerCase)) {
            return "text/x-fortran";
        }
        if ("f90".equals(lowerCase)) {
            return "text/x-fortran";
        }
        if ("f95".equals(lowerCase)) {
            return "text/x-fortran";
        }
        if ("fb2".equals(lowerCase)) {
            return "application/x-fictionbook+xml";
        }
        if ("fig".equals(lowerCase)) {
            return "image/x-xfig";
        }
        if ("fits".equals(lowerCase)) {
            return "image/fits";
        }
        if ("fl".equals(lowerCase)) {
            return "application/x-fluid";
        }
        if ("flac".equals(lowerCase)) {
            return "audio/x-flac";
        }
        if ("flc".equals(lowerCase)) {
            return "video/x-flic";
        }


        if ("fli".equals(lowerCase)) {
            return "video/x-flic";
        }


        if ("flv".equals(lowerCase)) {
            return "video/x-flv";
        }
        if ("flw".equals(lowerCase)) {
            return "application/x-kivio";
        }
        if ("fo".equals(lowerCase)) {
            return "text/x-xslfo";
        }
        if ("for".equals(lowerCase)) {
            return "text/x-fortran";
        }
        if ("g3".equals(lowerCase)) {
            return "image/fax-g3";
        }
        if ("gb".equals(lowerCase)) {
            return "application/x-gameboy-rom";
        }
        if ("gba".equals(lowerCase)) {
            return "application/x-gba-rom";
        }
        if ("gcrd".equals(lowerCase)) {
            return "text/directory";
        }
        if ("ged".equals(lowerCase)) {
            return "application/x-gedcom";
        }
        if ("gedcom".equals(lowerCase)) {
            return "application/x-gedcom";
        }
        if ("gen".equals(lowerCase)) {
            return "application/x-genesis-rom";
        }
        if ("gf".equals(lowerCase)) {
            return "application/x-tex-gf";
        }
        if ("gg".equals(lowerCase)) {
            return "application/x-sms-rom";
        }
        if ("gif".equals(lowerCase)) {
            return "image/gif";
        }
        if ("glade".equals(lowerCase)) {
            return "application/x-glade";
        }
        if ("gmo".equals(lowerCase)) {
            return "application/x-gettext-translation";
        }
        if ("gnc".equals(lowerCase)) {
            return "application/x-gnucash";
        }
        if ("gnd".equals(lowerCase)) {
            return "application/gnunet-directory";
        }
        if ("gnucash".equals(lowerCase)) {
            return "application/x-gnucash";
        }
        if ("gnumeric".equals(lowerCase)) {
            return "application/x-gnumeric";
        }
        if ("gnuplot".equals(lowerCase)) {
            return "application/x-gnuplot";
        }
        if ("gp".equals(lowerCase)) {
            return "application/x-gnuplot";
        }
        if ("gpg".equals(lowerCase)) {
            return "application/pgp-encrypted";
        }
        if ("gplt".equals(lowerCase)) {
            return "application/x-gnuplot";
        }
        if ("gra".equals(lowerCase)) {
            return "application/x-graphite";
        }
        if ("gsf".equals(lowerCase)) {
            return "application/x-font-type1";
        }
        if ("gsm".equals(lowerCase)) {
            return "audio/x-gsm";
        }
        if ("gtar".equals(lowerCase)) {
            return "application/x-tar";
        }
        if ("gv".equals(lowerCase)) {
            return "text/vnd.graphviz";
        }
        if ("gvp".equals(lowerCase)) {
            return "text/x-google-video-pointer";
        }
        if ("gz".equals(lowerCase)) {
            return "application/x-gzip";
        }
        if ("h".equals(lowerCase)) {
            return "text/x-chdr";
        }
        if ("h++".equals(lowerCase)) {
            return "text/x-c++hdr";
        }
        if ("hdf".equals(lowerCase)) {
            return "application/x-hdf";
        }
        if ("hh".equals(lowerCase)) {
            return "text/x-c++hdr";
        }
        if ("hp".equals(lowerCase)) {
            return "text/x-c++hdr";
        }
        if ("hpgl".equals(lowerCase)) {
            return "application/vnd.hp-hpgl";
        }
        if ("hpp".equals(lowerCase)) {
            return "text/x-c++hdr";
        }
        if ("hs".equals(lowerCase)) {
            return "text/x-haskell";
        }
        if ("htm".equals(lowerCase)) {
            return "text/html";
        }
        if ("html".equals(lowerCase)) {
            return "text/html";
        }
        if ("hwp".equals(lowerCase)) {
            return "application/x-hwp";
        }
        if ("hwt".equals(lowerCase)) {
            return "application/x-hwt";
        }
        if ("hxx".equals(lowerCase)) {
            return "text/x-c++hdr";
        }
        if ("ica".equals(lowerCase)) {
            return "application/x-ica";
        }
        if ("icb".equals(lowerCase)) {
            return "image/x-tga";
        }
        if ("icns".equals(lowerCase)) {
            return "image/x-icns";
        }
        if ("ico".equals(lowerCase)) {
            return "image/vnd.microsoft.icon";
        }
        if ("ics".equals(lowerCase)) {
            return "text/calendar";
        }
        if ("idl".equals(lowerCase)) {
            return "text/x-idl";
        }
        if ("ief".equals(lowerCase)) {
            return "image/ief";
        }
        if ("iff".equals(lowerCase)) {
            return "image/x-iff";
        }
        if ("ilbm".equals(lowerCase)) {
            return "image/x-ilbm";
        }
        if ("ime".equals(lowerCase)) {
            return "text/x-imelody";
        }
        if ("imy".equals(lowerCase)) {
            return "text/x-imelody";
        }
        if ("ins".equals(lowerCase)) {
            return "text/x-tex";
        }
        if ("iptables".equals(lowerCase)) {
            return "text/x-iptables";
        }
        if ("iso".equals(lowerCase)) {
            return "application/x-cd-image";
        }
        if ("iso9660".equals(lowerCase)) {
            return "application/x-cd-image";
        }
        if ("it".equals(lowerCase)) {
            return "audio/x-it";
        }
        if ("j2k".equals(lowerCase)) {
            return "image/jp2";
        }
        if ("jad".equals(lowerCase)) {
            return "text/vnd.sun.j2me.app-descriptor";
        }
        if ("jar".equals(lowerCase)) {
            return "application/x-java-archive";
        }
        if ("java".equals(lowerCase)) {
            return "text/x-java";
        }
        if ("jng".equals(lowerCase)) {
            return "image/x-jng";
        }
        if ("jnlp".equals(lowerCase)) {
            return "application/x-java-jnlp-file";
        }
        if ("jp2".equals(lowerCase)) {
            return "image/jp2";
        }
        if ("jpc".equals(lowerCase)) {
            return "image/jp2";
        }


        if ("jpe".equals(lowerCase)) {
            return "image/jpeg";
        }


        if ("jpeg".equals(lowerCase)) {
            return "image/jpeg";
        }
        if ("jpf".equals(lowerCase)) {
            return "image/jp2";
        }
        if ("jpg".equals(lowerCase)) {
            return "image/jpeg";
        }
        if ("jpr".equals(lowerCase)) {
            return "application/x-jbuilder-project";
        }
        if ("jpx".equals(lowerCase)) {
            return "image/jp2";
        }
        if ("js".equals(lowerCase)) {
            return "application/javascript";
        }
        if ("json".equals(lowerCase)) {
            return "application/json";
        }
        if ("jsonp".equals(lowerCase)) {
            return "application/jsonp";
        }
        if ("k25".equals(lowerCase)) {
            return "image/x-kodak-k25";
        }
        if ("kar".equals(lowerCase)) {
            return "audio/midi";
        }
        if ("karbon".equals(lowerCase)) {
            return "application/x-karbon";
        }
        if ("kdc".equals(lowerCase)) {
            return "image/x-kodak-kdc";
        }
        if ("kdelnk".equals(lowerCase)) {
            return "application/x-desktop";
        }
        if ("kexi".equals(lowerCase)) {
            return "application/x-kexiproject-sqlite3";
        }
        if ("kexic".equals(lowerCase)) {
            return "application/x-kexi-connectiondata";
        }
        if ("kexis".equals(lowerCase)) {
            return "application/x-kexiproject-shortcut";
        }
        if ("kfo".equals(lowerCase)) {
            return "application/x-kformula";
        }
        if ("kil".equals(lowerCase)) {
            return "application/x-killustrator";
        }
        if ("kino".equals(lowerCase)) {
            return "application/smil";
        }
        if ("kml".equals(lowerCase)) {
            return "application/vnd.google-earth.kml+xml";
        }
        if ("kmz".equals(lowerCase)) {
            return "application/vnd.google-earth.kmz";
        }
        if ("kon".equals(lowerCase)) {
            return "application/x-kontour";
        }
        if ("kpm".equals(lowerCase)) {
            return "application/x-kpovmodeler";
        }
        if ("kpr".equals(lowerCase)) {
            return "application/x-kpresenter";
        }
        if ("kpt".equals(lowerCase)) {
            return "application/x-kpresenter";
        }
        if ("kra".equals(lowerCase)) {
            return "application/x-krita";
        }
        if ("ksp".equals(lowerCase)) {
            return "application/x-kspread";
        }
        if ("kud".equals(lowerCase)) {
            return "application/x-kugar";
        }
        if ("kwd".equals(lowerCase)) {
            return "application/x-kword";
        }
        if ("kwt".equals(lowerCase)) {
            return "application/x-kword";
        }
        if ("la".equals(lowerCase)) {
            return "application/x-shared-library-la";
        }
        if ("latex".equals(lowerCase)) {
            return "text/x-tex";
        }
        if ("ldif".equals(lowerCase)) {
            return "text/x-ldif";
        }
        if ("lha".equals(lowerCase)) {
            return "application/x-lha";
        }
        if ("lhs".equals(lowerCase)) {
            return "text/x-literate-haskell";
        }
        if ("lhz".equals(lowerCase)) {
            return "application/x-lhz";
        }
        if ("log".equals(lowerCase)) {
            return "text/x-log";
        }
        if ("ltx".equals(lowerCase)) {
            return "text/x-tex";
        }
        if ("lua".equals(lowerCase)) {
            return "text/x-lua";
        }
        if ("lwo".equals(lowerCase)) {
            return "image/x-lwo";
        }
        if ("lwob".equals(lowerCase)) {
            return "image/x-lwo";
        }
        if ("lws".equals(lowerCase)) {
            return "image/x-lws";
        }
        if ("ly".equals(lowerCase)) {
            return "text/x-lilypond";
        }
        if ("lyx".equals(lowerCase)) {
            return "application/x-lyx";
        }
        if ("lz".equals(lowerCase)) {
            return "application/x-lzip";
        }
        if ("lzh".equals(lowerCase)) {
            return "application/x-lha";
        }
        if ("lzma".equals(lowerCase)) {
            return "application/x-lzma";
        }
        if ("lzo".equals(lowerCase)) {
            return "application/x-lzop";
        }
        if ("m".equals(lowerCase)) {
            return "text/x-matlab";
        }
        if ("m15".equals(lowerCase)) {
            return "audio/x-mod";
        }
        if ("m2t".equals(lowerCase)) {
            return "video/mpeg";
        }
        if ("m3u".equals(lowerCase)) {
            return "audio/x-mpegurl";
        }
        if ("m3u8".equals(lowerCase)) {
            return "audio/x-mpegurl";
        }
        if ("m4".equals(lowerCase)) {
            return "application/x-m4";
        }
        if ("m4a".equals(lowerCase)) {
            return "audio/mp4";
        }
        if ("m4b".equals(lowerCase)) {
            return "audio/x-m4b";
        }
        if ("m4v".equals(lowerCase)) {
            return "video/mp4";
        }
        if ("mab".equals(lowerCase)) {
            return "application/x-markaby";
        }
        if ("man".equals(lowerCase)) {
            return "application/x-troff-man";
        }
        if ("mbox".equals(lowerCase)) {
            return "application/mbox";
        }
        if ("md".equals(lowerCase)) {
            return "application/x-genesis-rom";
        }


        if ("mdb".equals(lowerCase)) {
            return "application/vnd.ms-access";
        }


        if ("mdi".equals(lowerCase)) {
            return "image/vnd.ms-modi";
        }
        if ("me".equals(lowerCase)) {
            return "text/x-troff-me";
        }
        if ("med".equals(lowerCase)) {
            return "audio/x-mod";
        }
        if ("metalink".equals(lowerCase)) {
            return "application/metalink+xml";
        }
        if ("mgp".equals(lowerCase)) {
            return "application/x-magicpoint";
        }
        if ("mid".equals(lowerCase)) {
            return "audio/midi";
        }
        if ("midi".equals(lowerCase)) {
            return "audio/midi";
        }
        if ("mif".equals(lowerCase)) {
            return "application/x-mif";
        }
        if ("minipsf".equals(lowerCase)) {
            return "audio/x-minipsf";
        }
        if ("mka".equals(lowerCase)) {
            return "audio/x-matroska";
        }
        if ("mkv".equals(lowerCase)) {
            return "video/x-matroska";
        }
        if ("ml".equals(lowerCase)) {
            return "text/x-ocaml";
        }
        if ("mli".equals(lowerCase)) {
            return "text/x-ocaml";
        }
        if ("mm".equals(lowerCase)) {
            return "text/x-troff-mm";
        }
        if ("mmf".equals(lowerCase)) {
            return "application/x-smaf";
        }
        if ("mml".equals(lowerCase)) {
            return "text/mathml";
        }
        if ("mng".equals(lowerCase)) {
            return "video/x-mng";
        }
        if ("mo".equals(lowerCase)) {
            return "application/x-gettext-translation";
        }
        if ("mo3".equals(lowerCase)) {
            return "audio/x-mo3";
        }
        if ("moc".equals(lowerCase)) {
            return "text/x-moc";
        }
        if ("mod".equals(lowerCase)) {
            return "audio/x-mod";
        }
        if ("mof".equals(lowerCase)) {
            return "text/x-mof";
        }
        if ("moov".equals(lowerCase)) {
            return "video/quicktime";
        }
        if ("mov".equals(lowerCase)) {
            return "video/quicktime";
        }
        if ("movie".equals(lowerCase)) {
            return "video/x-sgi-movie";
        }
        if ("mp+".equals(lowerCase)) {
            return "audio/x-musepack";
        }
        if ("mp2".equals(lowerCase)) {
            return "video/mpeg";
        }
        if ("mp3".equals(lowerCase)) {
            return "audio/mpeg";
        }
        if ("mp4".equals(lowerCase)) {
            return "video/mp4";
        }
        if ("mpc".equals(lowerCase)) {
            return "audio/x-musepack";
        }
        if ("mpe".equals(lowerCase)) {
            return "video/mpeg";
        }
        if ("mpeg".equals(lowerCase)) {
            return "video/mpeg";
        }
        if ("mpg".equals(lowerCase)) {
            return "video/mpeg";
        }
        if ("mpga".equals(lowerCase)) {
            return "audio/mpeg";
        }
        if ("mpp".equals(lowerCase)) {
            return "audio/x-musepack";
        }
        if ("mrl".equals(lowerCase)) {
            return "text/x-mrml";
        }
        if ("mrml".equals(lowerCase)) {
            return "text/x-mrml";
        }
        if ("mrw".equals(lowerCase)) {
            return "image/x-minolta-mrw";
        }
        if ("ms".equals(lowerCase)) {
            return "text/x-troff-ms";
        }
        if ("msi".equals(lowerCase)) {
            return "application/x-msi";
        }
        if ("msod".equals(lowerCase)) {
            return "image/x-msod";
        }
        if ("msx".equals(lowerCase)) {
            return "application/x-msx-rom";
        }
        if ("mtm".equals(lowerCase)) {
            return "audio/x-mod";
        }
        if ("mup".equals(lowerCase)) {
            return "text/x-mup";
        }
        if ("mxf".equals(lowerCase)) {
            return "application/mxf";
        }
        if ("n64".equals(lowerCase)) {
            return "application/x-n64-rom";
        }
        if ("nb".equals(lowerCase)) {
            return "application/mathematica";
        }
        if ("nc".equals(lowerCase)) {
            return "application/x-netcdf";
        }
        if ("nds".equals(lowerCase)) {
            return "application/x-nintendo-ds-rom";
        }
        if ("nef".equals(lowerCase)) {
            return "image/x-nikon-nef";
        }
        if ("nes".equals(lowerCase)) {
            return "application/x-nes-rom";
        }
        if ("nfo".equals(lowerCase)) {
            return "text/x-nfo";
        }
        if ("not".equals(lowerCase)) {
            return "text/x-mup";
        }
        if ("nsc".equals(lowerCase)) {
            return "application/x-netshow-channel";
        }
        if ("nsv".equals(lowerCase)) {
            return "video/x-nsv";
        }
        if ("o".equals(lowerCase)) {
            return "application/x-object";
        }
        if ("obj".equals(lowerCase)) {
            return "application/x-tgif";
        }
        if ("ocl".equals(lowerCase)) {
            return "text/x-ocl";
        }
        if ("oda".equals(lowerCase)) {
            return "application/oda";
        }
        if ("odb".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.database";
        }
        if ("odc".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.chart";
        }
        if ("odf".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.formula";
        }
        if ("odg".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.graphics";
        }
        if ("odi".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.image";
        }
        if ("odm".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.text-master";
        }
        if ("odp".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.presentation";
        }
        if ("ods".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.spreadsheet";
        }
        if ("odt".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.text";
        }
        if ("oga".equals(lowerCase)) {
            return "audio/ogg";
        }
        if ("ogg".equals(lowerCase)) {
            return "video/x-theora+ogg";
        }
        if ("ogm".equals(lowerCase)) {
            return "video/x-ogm+ogg";
        }
        if ("ogv".equals(lowerCase)) {
            return "video/ogg";
        }


        if ("ogx".equals(lowerCase)) {
            return "application/ogg";
        }


        if ("old".equals(lowerCase)) {
            return "application/x-trash";
        }
        if ("oleo".equals(lowerCase)) {
            return "application/x-oleo";
        }
        if ("opml".equals(lowerCase)) {
            return "text/x-opml+xml";
        }
        if ("ora".equals(lowerCase)) {
            return "image/openraster";
        }
        if ("orf".equals(lowerCase)) {
            return "image/x-olympus-orf";
        }
        if ("otc".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.chart-template";
        }
        if ("otf".equals(lowerCase)) {
            return "application/x-font-otf";
        }
        if ("otg".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.graphics-template";
        }
        if ("oth".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.text-web";
        }
        if ("otp".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.presentation-template";
        }
        if ("ots".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.spreadsheet-template";
        }
        if ("ott".equals(lowerCase)) {
            return "application/vnd.oasis.opendocument.text-template";
        }
        if ("owl".equals(lowerCase)) {
            return "application/rdf+xml";
        }
        if ("oxt".equals(lowerCase)) {
            return "application/vnd.openofficeorg.extension";
        }
        if ("p".equals(lowerCase)) {
            return "text/x-pascal";
        }
        if ("p10".equals(lowerCase)) {
            return "application/pkcs10";
        }
        if ("p12".equals(lowerCase)) {
            return "application/x-pkcs12";
        }
        if ("p7b".equals(lowerCase)) {
            return "application/x-pkcs7-certificates";
        }
        if ("p7s".equals(lowerCase)) {
            return "application/pkcs7-signature";
        }
        if ("pack".equals(lowerCase)) {
            return "application/x-java-pack200";
        }
        if ("pak".equals(lowerCase)) {
            return "application/x-pak";
        }
        if ("par2".equals(lowerCase)) {
            return "application/x-par2";
        }
        if ("pas".equals(lowerCase)) {
            return "text/x-pascal";
        }
        if ("patch".equals(lowerCase)) {
            return "text/x-patch";
        }
        if ("pbm".equals(lowerCase)) {
            return "image/x-portable-bitmap";
        }
        if ("pcd".equals(lowerCase)) {
            return "image/x-photo-cd";
        }
        if ("pcf".equals(lowerCase)) {
            return "application/x-cisco-vpn-settings";
        }
        if ("pcf.gz".equals(lowerCase)) {
            return "application/x-font-pcf";
        }
        if ("pcf.z".equals(lowerCase)) {
            return "application/x-font-pcf";
        }
        if ("pcl".equals(lowerCase)) {
            return "application/vnd.hp-pcl";
        }
        if ("pcx".equals(lowerCase)) {
            return "image/x-pcx";
        }
        if ("pdb".equals(lowerCase)) {
            return "chemical/x-pdb";
        }
        if ("pdc".equals(lowerCase)) {
            return "application/x-aportisdoc";
        }
        if ("pdf".equals(lowerCase)) {
            return "application/pdf";
        }
        if ("pdf.bz2".equals(lowerCase)) {
            return "application/x-bzpdf";
        }
        if ("pdf.gz".equals(lowerCase)) {
            return "application/x-gzpdf";
        }
        if ("pef".equals(lowerCase)) {
            return "image/x-pentax-pef";
        }
        if ("pem".equals(lowerCase)) {
            return "application/x-x509-ca-cert";
        }
        if ("perl".equals(lowerCase)) {
            return "application/x-perl";
        }
        if ("pfa".equals(lowerCase)) {
            return "application/x-font-type1";
        }
        if ("pfb".equals(lowerCase)) {
            return "application/x-font-type1";
        }
        if ("pfx".equals(lowerCase)) {
            return "application/x-pkcs12";
        }
        if ("pgm".equals(lowerCase)) {
            return "image/x-portable-graymap";
        }
        if ("pgn".equals(lowerCase)) {
            return "application/x-chess-pgn";
        }
        if ("pgp".equals(lowerCase)) {
            return "application/pgp-encrypted";
        }
        if ("php".equals(lowerCase)) {
            return "application/x-php";
        }
        if ("php3".equals(lowerCase)) {
            return "application/x-php";
        }
        if ("php4".equals(lowerCase)) {
            return "application/x-php";
        }
        if ("pict".equals(lowerCase)) {
            return "image/x-pict";
        }
        if ("pict1".equals(lowerCase)) {
            return "image/x-pict";
        }
        if ("pict2".equals(lowerCase)) {
            return "image/x-pict";
        }
        if ("pickle".equals(lowerCase)) {
            return "application/python-pickle";
        }
        if ("pk".equals(lowerCase)) {
            return "application/x-tex-pk";
        }
        if ("pkipath".equals(lowerCase)) {
            return "application/pkix-pkipath";
        }
        if ("pkr".equals(lowerCase)) {
            return "application/pgp-keys";
        }
        if ("pl".equals(lowerCase)) {
            return "application/x-perl";
        }
        if ("pla".equals(lowerCase)) {
            return "audio/x-iriver-pla";
        }
        if ("pln".equals(lowerCase)) {
            return "application/x-planperfect";
        }
        if ("pls".equals(lowerCase)) {
            return "audio/x-scpls";
        }
        if ("pm".equals(lowerCase)) {
            return "application/x-perl";
        }
        if ("png".equals(lowerCase)) {
            return "image/png";
        }
        if ("pnm".equals(lowerCase)) {
            return "image/x-portable-anymap";
        }
        if ("pntg".equals(lowerCase)) {
            return "image/x-macpaint";
        }
        if ("po".equals(lowerCase)) {
            return "text/x-gettext-translation";
        }
        if ("por".equals(lowerCase)) {
            return "application/x-spss-por";
        }
        if ("pot".equals(lowerCase)) {
            return "text/x-gettext-translation-template";
        }
        if ("ppm".equals(lowerCase)) {
            return "image/x-portable-pixmap";
        }
        if ("pps".equals(lowerCase)) {
            return "application/vnd.ms-powerpoint";
        }
        if ("ppt".equals(lowerCase)) {
            return "application/vnd.ms-powerpoint";
        }
        if ("pptm".equals(lowerCase)) {
            return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
        }
        if ("pptx".equals(lowerCase)) {
            return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
        }
        if ("ppz".equals(lowerCase)) {
            return "application/vnd.ms-powerpoint";
        }
        if ("prc".equals(lowerCase)) {
            return "application/x-palm-database";
        }
        if ("ps".equals(lowerCase)) {
            return "application/postscript";
        }
        if ("ps.bz2".equals(lowerCase)) {
            return "application/x-bzpostscript";
        }
        if ("ps.gz".equals(lowerCase)) {
            return "application/x-gzpostscript";
        }


        if ("psd".equals(lowerCase)) {
            return "image/vnd.adobe.photoshop";
        }


        if ("psf".equals(lowerCase)) {
            return "audio/x-psf";
        }
        if ("psf.gz".equals(lowerCase)) {
            return "application/x-gz-font-linux-psf";
        }
        if ("psflib".equals(lowerCase)) {
            return "audio/x-psflib";
        }
        if ("psid".equals(lowerCase)) {
            return "audio/prs.sid";
        }
        if ("psw".equals(lowerCase)) {
            return "application/x-pocket-word";
        }
        if ("pw".equals(lowerCase)) {
            return "application/x-pw";
        }
        if ("py".equals(lowerCase)) {
            return "text/x-python";
        }
        if ("pyc".equals(lowerCase)) {
            return "application/x-python-bytecode";
        }
        if ("pyo".equals(lowerCase)) {
            return "application/x-python-bytecode";
        }
        if ("qif".equals(lowerCase)) {
            return "image/x-quicktime";
        }
        if ("qt".equals(lowerCase)) {
            return "video/quicktime";
        }
        if ("qtif".equals(lowerCase)) {
            return "image/x-quicktime";
        }
        if ("qtl".equals(lowerCase)) {
            return "application/x-quicktime-media-link";
        }
        if ("qtvr".equals(lowerCase)) {
            return "video/quicktime";
        }
        if ("ra".equals(lowerCase)) {
            return "audio/vnd.rn-realaudio";
        }
        if ("raf".equals(lowerCase)) {
            return "image/x-fuji-raf";
        }
        if ("ram".equals(lowerCase)) {
            return "application/ram";
        }
        if ("rar".equals(lowerCase)) {
            return "application/x-rar";
        }
        if ("ras".equals(lowerCase)) {
            return "image/x-cmu-raster";
        }
        if ("raw".equals(lowerCase)) {
            return "image/x-panasonic-raw";
        }
        if ("rax".equals(lowerCase)) {
            return "audio/vnd.rn-realaudio";
        }
        if ("rb".equals(lowerCase)) {
            return "application/x-ruby";
        }
        if ("rdf".equals(lowerCase)) {
            return "application/rdf+xml";
        }
        if ("rdfs".equals(lowerCase)) {
            return "application/rdf+xml";
        }
        if ("reg".equals(lowerCase)) {
            return "text/x-ms-regedit";
        }
        if ("rej".equals(lowerCase)) {
            return "application/x-reject";
        }
        if ("rgb".equals(lowerCase)) {
            return "image/x-rgb";
        }
        if ("rle".equals(lowerCase)) {
            return "image/rle";
        }
        if ("rm".equals(lowerCase)) {
            return "application/vnd.rn-realmedia";
        }
        if ("rmj".equals(lowerCase)) {
            return "application/vnd.rn-realmedia";
        }
        if ("rmm".equals(lowerCase)) {
            return "application/vnd.rn-realmedia";
        }
        if ("rms".equals(lowerCase)) {
            return "application/vnd.rn-realmedia";
        }
        if ("rmvb".equals(lowerCase)) {
            return "application/vnd.rn-realmedia";
        }
        if ("rmx".equals(lowerCase)) {
            return "application/vnd.rn-realmedia";
        }
        if ("roff".equals(lowerCase)) {
            return "text/troff";
        }
        if ("rp".equals(lowerCase)) {
            return "image/vnd.rn-realpix";
        }
        if ("rpm".equals(lowerCase)) {
            return "application/x-rpm";
        }
        if ("rss".equals(lowerCase)) {
            return "application/rss+xml";
        }
        if ("rt".equals(lowerCase)) {
            return "text/vnd.rn-realtext";
        }
        if ("rtf".equals(lowerCase)) {
            return "application/rtf";
        }
        if ("rtx".equals(lowerCase)) {
            return "text/richtext";
        }
        if ("rv".equals(lowerCase)) {
            return "video/vnd.rn-realvideo";
        }
        if ("rvx".equals(lowerCase)) {
            return "video/vnd.rn-realvideo";
        }
        if ("s3m".equals(lowerCase)) {
            return "audio/x-s3m";
        }
        if ("sam".equals(lowerCase)) {
            return "application/x-amipro";
        }
        if ("sami".equals(lowerCase)) {
            return "application/x-sami";
        }
        if ("sav".equals(lowerCase)) {
            return "application/x-spss-sav";
        }
        if ("scm".equals(lowerCase)) {
            return "text/x-scheme";
        }
        if ("sda".equals(lowerCase)) {
            return "application/vnd.stardivision.draw";
        }
        if ("sdc".equals(lowerCase)) {
            return "application/vnd.stardivision.calc";
        }
        if ("sdd".equals(lowerCase)) {
            return "application/vnd.stardivision.impress";
        }
        if ("sdp".equals(lowerCase)) {
            return "application/sdp";
        }
        if ("sds".equals(lowerCase)) {
            return "application/vnd.stardivision.chart";
        }
        if ("sdw".equals(lowerCase)) {
            return "application/vnd.stardivision.writer";
        }
        if ("sgf".equals(lowerCase)) {
            return "application/x-go-sgf";
        }
        if ("sgi".equals(lowerCase)) {
            return "image/x-sgi";
        }
        if ("sgl".equals(lowerCase)) {
            return "application/vnd.stardivision.writer";
        }
        if ("sgm".equals(lowerCase)) {
            return "text/sgml";
        }
        if ("sgml".equals(lowerCase)) {
            return "text/sgml";
        }
        if ("sh".equals(lowerCase)) {
            return "application/x-shellscript";
        }
        if ("shar".equals(lowerCase)) {
            return "application/x-shar";
        }
        if ("shn".equals(lowerCase)) {
            return "application/x-shorten";
        }
        if ("siag".equals(lowerCase)) {
            return "application/x-siag";
        }
        if ("sid".equals(lowerCase)) {
            return "audio/prs.sid";
        }
        if ("sik".equals(lowerCase)) {
            return "application/x-trash";
        }
        if ("sis".equals(lowerCase)) {
            return "application/vnd.symbian.install";
        }
        if ("sisx".equals(lowerCase)) {
            return "x-epoc/x-sisx-app";
        }
        if ("sit".equals(lowerCase)) {
            return "application/x-stuffit";
        }
        if ("siv".equals(lowerCase)) {
            return "application/sieve";
        }
        if ("sk".equals(lowerCase)) {
            return "image/x-skencil";
        }
        if ("sk1".equals(lowerCase)) {
            return "image/x-skencil";
        }
        if ("skr".equals(lowerCase)) {
            return "application/pgp-keys";
        }
        if ("slk".equals(lowerCase)) {
            return "text/spreadsheet";
        }
        if ("smaf".equals(lowerCase)) {
            return "application/x-smaf";
        }
        if ("smc".equals(lowerCase)) {
            return "application/x-snes-rom";
        }
        if ("smd".equals(lowerCase)) {
            return "application/vnd.stardivision.mail";
        }
        if ("smf".equals(lowerCase)) {
            return "application/vnd.stardivision.math";
        }
        if ("smi".equals(lowerCase)) {
            return "application/x-sami";
        }
        if ("smil".equals(lowerCase)) {
            return "application/smil";
        }
        if ("sml".equals(lowerCase)) {
            return "application/smil";
        }
        if ("sms".equals(lowerCase)) {
            return "application/x-sms-rom";
        }
        if ("snd".equals(lowerCase)) {
            return "audio/basic";
        }
        if ("so".equals(lowerCase)) {
            return "application/x-sharedlib";
        }
        if ("spc".equals(lowerCase)) {
            return "application/x-pkcs7-certificates";
        }
        if ("spd".equals(lowerCase)) {
            return "application/x-font-speedo";
        }
        if ("spec".equals(lowerCase)) {
            return "text/x-rpm-spec";
        }
        if ("spl".equals(lowerCase)) {
            return "application/x-shockwave-flash";
        }
        if ("spx".equals(lowerCase)) {
            return "audio/x-speex";
        }
        if ("sql".equals(lowerCase)) {
            return "text/x-sql";
        }
        if ("sr2".equals(lowerCase)) {
            return "image/x-sony-sr2";
        }
        if ("src".equals(lowerCase)) {
            return "application/x-wais-source";
        }
        if ("srf".equals(lowerCase)) {
            return "image/x-sony-srf";
        }
        if ("srt".equals(lowerCase)) {
            return "application/x-subrip";
        }
        if ("ssa".equals(lowerCase)) {
            return "text/x-ssa";
        }
        if ("stc".equals(lowerCase)) {
            return "application/vnd.sun.xml.calc.template";
        }
        if ("std".equals(lowerCase)) {
            return "application/vnd.sun.xml.draw.template";
        }
        if ("sti".equals(lowerCase)) {
            return "application/vnd.sun.xml.impress.template";
        }
        if ("stm".equals(lowerCase)) {
            return "audio/x-stm";
        }
        if ("stw".equals(lowerCase)) {
            return "application/vnd.sun.xml.writer.template";
        }
        if ("sty".equals(lowerCase)) {
            return "text/x-tex";
        }
        if ("sub".equals(lowerCase)) {
            return "text/x-subviewer";
        }
        if ("sun".equals(lowerCase)) {
            return "image/x-sun-raster";
        }
        if ("sv4cpio".equals(lowerCase)) {
            return "application/x-sv4cpio";
        }
        if ("sv4crc".equals(lowerCase)) {
            return "application/x-sv4crc";
        }
        if ("svg".equals(lowerCase)) {
            return "image/svg+xml";
        }
        if ("svgz".equals(lowerCase)) {
            return "image/svg+xml-compressed";
        }
        if ("swf".equals(lowerCase)) {
            return "application/x-shockwave-flash";
        }
        if ("sxc".equals(lowerCase)) {
            return "application/vnd.sun.xml.calc";
        }
        if ("sxd".equals(lowerCase)) {
            return "application/vnd.sun.xml.draw";
        }
        if ("sxg".equals(lowerCase)) {
            return "application/vnd.sun.xml.writer.global";
        }
        if ("sxi".equals(lowerCase)) {
            return "application/vnd.sun.xml.impress";
        }
        if ("sxm".equals(lowerCase)) {
            return "application/vnd.sun.xml.math";
        }
        if ("sxw".equals(lowerCase)) {
            return "application/vnd.sun.xml.writer";
        }
        if ("sylk".equals(lowerCase)) {
            return "text/spreadsheet";
        }
        if ("t".equals(lowerCase)) {
            return "text/troff";
        }
        if ("t2t".equals(lowerCase)) {
            return "text/x-txt2tags";
        }
        if ("tar".equals(lowerCase)) {
            return "application/x-tar";
        }
        if ("tar.bz".equals(lowerCase)) {
            return "application/x-bzip-compressed-tar";
        }
        if ("tar.bz2".equals(lowerCase)) {
            return "application/x-bzip-compressed-tar";
        }
        if ("tar.gz".equals(lowerCase)) {
            return "application/x-compressed-tar";
        }
        if ("tar.lzma".equals(lowerCase)) {
            return "application/x-lzma-compressed-tar";
        }
        if ("tar.lzo".equals(lowerCase)) {
            return "application/x-tzo";
        }
        if ("tar.xz".equals(lowerCase)) {
            return "application/x-xz-compressed-tar";
        }
        if ("tar.z".equals(lowerCase)) {
            return "application/x-tarz";
        }
        if ("tbz".equals(lowerCase)) {
            return "application/x-bzip-compressed-tar";
        }
        if ("tbz2".equals(lowerCase)) {
            return "application/x-bzip-compressed-tar";
        }
        if ("tcl".equals(lowerCase)) {
            return "text/x-tcl";
        }
        if ("tex".equals(lowerCase)) {
            return "text/x-tex";
        }
        if ("texi".equals(lowerCase)) {
            return "text/x-texinfo";
        }
        if ("texinfo".equals(lowerCase)) {
            return "text/x-texinfo";
        }
        if ("tga".equals(lowerCase)) {
            return "image/x-tga";
        }
        if ("tgz".equals(lowerCase)) {
            return "application/x-compressed-tar";
        }
        if ("theme".equals(lowerCase)) {
            return "application/x-theme";
        }
        if ("themepack".equals(lowerCase)) {
            return "application/x-windows-themepack";
        }
        if ("tif".equals(lowerCase)) {
            return "image/tiff";
        }
        if ("tiff".equals(lowerCase)) {
            return "image/tiff";
        }
        if ("tk".equals(lowerCase)) {
            return "text/x-tcl";
        }
        if ("tlz".equals(lowerCase)) {
            return "application/x-lzma-compressed-tar";
        }
        if ("tnef".equals(lowerCase)) {
            return "application/vnd.ms-tnef";
        }
        if ("tnf".equals(lowerCase)) {
            return "application/vnd.ms-tnef";
        }
        if ("toc".equals(lowerCase)) {
            return "application/x-cdrdao-toc";
        }
        if ("torrent".equals(lowerCase)) {
            return "application/x-bittorrent";
        }
        if ("tpic".equals(lowerCase)) {
            return "image/x-tga";
        }
        if ("tr".equals(lowerCase)) {
            return "text/troff";
        }
        if ("ts".equals(lowerCase)) {
            return "application/x-linguist";
        }
        if ("tsv".equals(lowerCase)) {
            return "text/tab-separated-values";
        }
        if ("tta".equals(lowerCase)) {
            return "audio/x-tta";
        }
        if ("ttc".equals(lowerCase)) {
            return "application/x-font-ttf";
        }
        if ("ttf".equals(lowerCase)) {
            return "application/x-font-ttf";
        }
        if ("ttx".equals(lowerCase)) {
            return "application/x-font-ttx";
        }
        if ("txt".equals(lowerCase)) {
            return "text/plain";
        }
        if ("txz".equals(lowerCase)) {
            return "application/x-xz-compressed-tar";
        }
        if ("tzo".equals(lowerCase)) {
            return "application/x-tzo";
        }
        if ("ufraw".equals(lowerCase)) {
            return "application/x-ufraw";
        }
        if ("ui".equals(lowerCase)) {
            return "application/x-designer";
        }
        if ("uil".equals(lowerCase)) {
            return "text/x-uil";
        }
        if ("ult".equals(lowerCase)) {
            return "audio/x-mod";
        }
        if ("uni".equals(lowerCase)) {
            return "audio/x-mod";
        }
        if ("uri".equals(lowerCase)) {
            return "text/x-uri";
        }
        if ("url".equals(lowerCase)) {
            return "text/x-uri";
        }
        if ("ustar".equals(lowerCase)) {
            return "application/x-ustar";
        }
        if ("vala".equals(lowerCase)) {
            return "text/x-vala";
        }
        if ("vapi".equals(lowerCase)) {
            return "text/x-vala";
        }
        if ("vcf".equals(lowerCase)) {
            return "text/directory";
        }
        if ("vcs".equals(lowerCase)) {
            return "text/calendar";
        }
        if ("vct".equals(lowerCase)) {
            return "text/directory";
        }
        if ("vda".equals(lowerCase)) {
            return "image/x-tga";
        }
        if ("vhd".equals(lowerCase)) {
            return "text/x-vhdl";
        }
        if ("vhdl".equals(lowerCase)) {
            return "text/x-vhdl";
        }
        if ("viv".equals(lowerCase)) {
            return "video/vivo";
        }
        if ("vivo".equals(lowerCase)) {
            return "video/vivo";
        }
        if ("vlc".equals(lowerCase)) {
            return "audio/x-mpegurl";
        }
        if ("vob".equals(lowerCase)) {
            return "video/mpeg";
        }
        if ("voc".equals(lowerCase)) {
            return "audio/x-voc";
        }
        if ("vor".equals(lowerCase)) {
            return "application/vnd.stardivision.writer";
        }
        if ("vst".equals(lowerCase)) {
            return "image/x-tga";
        }
        if ("wav".equals(lowerCase)) {
            return "audio/x-wav";
        }
        if ("wax".equals(lowerCase)) {
            return "audio/x-ms-asx";
        }
        if ("wb1".equals(lowerCase)) {
            return "application/x-quattropro";
        }
        if ("wb2".equals(lowerCase)) {
            return "application/x-quattropro";
        }
        if ("wb3".equals(lowerCase)) {
            return "application/x-quattropro";
        }
        if ("wbmp".equals(lowerCase)) {
            return "image/vnd.wap.wbmp";
        }
        if ("wcm".equals(lowerCase)) {
            return "application/vnd.ms-works";
        }
        if ("wdb".equals(lowerCase)) {
            return "application/vnd.ms-works";
        }
        if ("webm".equals(lowerCase)) {
            return "video/webm";
        }
        if ("wk1".equals(lowerCase)) {
            return "application/vnd.lotus-1-2-3";
        }
        if ("wk3".equals(lowerCase)) {
            return "application/vnd.lotus-1-2-3";
        }
        if ("wk4".equals(lowerCase)) {
            return "application/vnd.lotus-1-2-3";
        }
        if ("wks".equals(lowerCase)) {
            return "application/vnd.ms-works";
        }
        if ("wma".equals(lowerCase)) {
            return "audio/x-ms-wma";
        }
        if ("wmf".equals(lowerCase)) {
            return "image/x-wmf";
        }
        if ("wml".equals(lowerCase)) {
            return "text/vnd.wap.wml";
        }
        if ("wmls".equals(lowerCase)) {
            return "text/vnd.wap.wmlscript";
        }
        if ("wmv".equals(lowerCase)) {
            return "video/x-ms-wmv";
        }
        if ("wmx".equals(lowerCase)) {
            return "audio/x-ms-asx";
        }
        if ("wp".equals(lowerCase)) {
            return "application/vnd.wordperfect";
        }
        if ("wp4".equals(lowerCase)) {
            return "application/vnd.wordperfect";
        }
        if ("wp5".equals(lowerCase)) {
            return "application/vnd.wordperfect";
        }
        if ("wp6".equals(lowerCase)) {
            return "application/vnd.wordperfect";
        }
        if ("wpd".equals(lowerCase)) {
            return "application/vnd.wordperfect";
        }
        if ("wpg".equals(lowerCase)) {
            return "application/x-wpg";
        }
        if ("wpl".equals(lowerCase)) {
            return "application/vnd.ms-wpl";
        }
        if ("wpp".equals(lowerCase)) {
            return "application/vnd.wordperfect";
        }
        if ("wps".equals(lowerCase)) {
            return "application/vnd.ms-works";
        }
        if ("wri".equals(lowerCase)) {
            return "application/x-mswrite";
        }
        if ("wrl".equals(lowerCase)) {
            return "model/vrml";
        }
        if ("wv".equals(lowerCase)) {
            return "audio/x-wavpack";
        }
        if ("wvc".equals(lowerCase)) {
            return "audio/x-wavpack-correction";
        }
        if ("wvp".equals(lowerCase)) {
            return "audio/x-wavpack";
        }
        if ("wvx".equals(lowerCase)) {
            return "audio/x-ms-asx";
        }
        if ("x3f".equals(lowerCase)) {
            return "image/x-sigma-x3f";
        }
        if ("xac".equals(lowerCase)) {
            return "application/x-gnucash";
        }
        if ("xbel".equals(lowerCase)) {
            return "application/x-xbel";
        }
        if ("xbl".equals(lowerCase)) {
            return "application/xml";
        }
        if ("xbm".equals(lowerCase)) {
            return "image/x-xbitmap";
        }
        if ("xcf".equals(lowerCase)) {
            return "image/x-xcf";
        }
        if ("xcf.bz2".equals(lowerCase)) {
            return "image/x-compressed-xcf";
        }
        if ("xcf.gz".equals(lowerCase)) {
            return "image/x-compressed-xcf";
        }
        if ("xhtml".equals(lowerCase)) {
            return "application/xhtml+xml";
        }
        if ("xi".equals(lowerCase)) {
            return "audio/x-xi";
        }
        if ("xla".equals(lowerCase)) {
            return "application/vnd.ms-excel";
        }
        if ("xlc".equals(lowerCase)) {
            return "application/vnd.ms-excel";
        }
        if ("xld".equals(lowerCase)) {
            return "application/vnd.ms-excel";
        }
        if ("xlf".equals(lowerCase)) {
            return "application/x-xliff";
        }
        if ("xliff".equals(lowerCase)) {
            return "application/x-xliff";
        }
        if ("xll".equals(lowerCase)) {
            return "application/vnd.ms-excel";
        }
        if ("xlm".equals(lowerCase)) {
            return "application/vnd.ms-excel";
        }
        if ("xls".equals(lowerCase)) {
            return "application/vnd.ms-excel";
        }
        if ("xlsm".equals(lowerCase)) {
            return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        }
        if ("xlsx".equals(lowerCase)) {
            return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        }
        if ("xlt".equals(lowerCase)) {
            return "application/vnd.ms-excel";
        }
        if ("xlw".equals(lowerCase)) {
            return "application/vnd.ms-excel";
        }
        if ("xm".equals(lowerCase)) {
            return "audio/x-xm";
        }
        if ("xmf".equals(lowerCase)) {
            return "audio/x-xmf";
        }
        if ("xmi".equals(lowerCase)) {
            return "text/x-xmi";
        }
        if ("xml".equals(lowerCase)) {
            return "application/xml";
        }
        if ("xpm".equals(lowerCase)) {
            return "image/x-xpixmap";
        }
        if ("xps".equals(lowerCase)) {
            return "application/vnd.ms-xpsdocument";
        }
        if ("xsl".equals(lowerCase)) {
            return "application/xml";
        }
        if ("xslfo".equals(lowerCase)) {
            return "text/x-xslfo";
        }
        if ("xslt".equals(lowerCase)) {
            return "application/xml";
        }
        if ("xspf".equals(lowerCase)) {
            return "application/xspf+xml";
        }
        if ("xul".equals(lowerCase)) {
            return "application/vnd.mozilla.xul+xml";
        }
        if ("xwd".equals(lowerCase)) {
            return "image/x-xwindowdump";
        }
        if ("xyz".equals(lowerCase)) {
            return "chemical/x-pdb";
        }
        if ("xz".equals(lowerCase)) {
            return "application/x-xz";
        }
        if ("w2p".equals(lowerCase)) {
            return "application/w2p";
        }
        if ("z".equals(lowerCase)) {
            return "application/x-compress";
        }
        if ("zabw".equals(lowerCase)) {
            return "application/x-abiword";
        }
        if ("zip".equals(lowerCase)) {
            return "application/zip";
        }
        if ("zoo".equals(lowerCase)) {
            return "application/x-zoo";
        }
        return "application/octet-stream";
    }
}
